package cn.weibo.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;

@Entity
@Table(name = "users", catalog = "weibo")
public class UserEntity implements Serializable {
    @Id
    @Column(name = "userID")
    private long userID;

    @Column(name = "account")
    private String account;

    @Column(name = "userName")
    private String userName;

    @Column(name = "password")
    private String password;

    @Column(name = "gender")
    private int gender;

    @Column(name = "email")
    private String email;

    @Column(name = "introduce")
    private String introduce;

    @Column(name = "lastActivityDate")
    private Date lastActivityDate;

    @Column(name = "createdOn")
    private Date createdOn;

    @Column(name = "fansCount")
    private long fansCount;

    @Column(name = "followedCount")
    private long followedCount;

    @OneToMany(mappedBy = "userByUserId")
    private Set<FollowEntity> followedUsers; // this关注的用户

    @OneToMany(mappedBy = "userByFollowedId")
    private Set<FollowEntity> fansUsers;    //  关注this的用户

    public long getUserID() {
		return userID;
	}

	public void setUserID(long userID) {
		this.userID = userID;
	}

    public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public String getGenderText() {
        String genderText;
        if(this.gender == 1) {
        	genderText = "男";
        } else {
        	genderText = "女";
        }
        return genderText;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public Date getLastActivityDate() {
        return lastActivityDate;
    }

    public void setLastActivityDate(Date lastActivityDate) {
        this.lastActivityDate = lastActivityDate;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public long getFansCount() {
        return fansCount;
    }

    public void setFansCount(long fansCount) {
        this.fansCount = fansCount;
    }

    public long getFollowedCount() {
        return followedCount;
    }

    public void setFollowedCount(long followedCount) {
        this.followedCount = followedCount;
    }

    public Set<FollowEntity> getFollowedUsers() {
        return followedUsers;
    }

    public void setFollowedUsers(Set<FollowEntity> followedUsers) {
        this.followedUsers = followedUsers;
    }

    public Set<FollowEntity> getFansUsers() {
        return fansUsers;
    }

    public void setFansUsers(Set<FollowEntity> fansUsers) {
        this.fansUsers = fansUsers;
    }
}
